package com.lagou;

import com.lagou.bean.ConsumerComponent;
import com.lagou.filter.TPMonitorFilter;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.io.IOException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


public class AnnotationConsumerMain
{
    public static void main(String[] args) throws IOException {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        context.start();
        ConsumerComponent service = context.getBean(ConsumerComponent.class);

        ExecutorService executorService = Executors.newFixedThreadPool(10);

        for (int i = 0; i < 2000; i++)
        {
            executorService.execute(new Runnable()
            {
                @Override
                public void run()
                {
                    service.methodA();
                }
            });
            executorService.execute(new Runnable()
            {
                @Override
                public void run()
                {
                    service.methodB();
                }
            });
            executorService.execute(new Runnable()
            {
                @Override
                public void run()
                {
                    service.methodC();
                }
            });
        }

    }

    @Configuration
    @PropertySource("classpath:/dubbo-consumer.properties")
    @ComponentScan("com.lagou.bean")
    @EnableDubbo(scanBasePackages = "com.lagou.bean")
    static class ConsumerConfiguration {

    }
}
